﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicClass;
using S.Eartag.Domain;
using S.Eartag.Domain.Model;
using S.Eartag.Read.API.Application.Command.LamBingCommand;

namespace S.Eartag.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LamBingController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly IConfiguration configuration;

        public LamBingController(IMediator mediator, IConfiguration configuration)
        {
            this.mediator = mediator;
            this.configuration = configuration;
        }
        /// <summary>
        /// 产羔耳标-显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageInfoS<LamBing>> LamBingGet([FromQuery]LamBingGetCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 品种下拉框
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public  IActionResult GetBreed()
        {
            List<object> list= new List<object>();
            foreach (var item in Enum.GetValues<Breed>())
            {
                list.Add(new 
                {
                    name=item.ToString(),
                    value=item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 出生状态下拉框
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetinsertType()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<StateBirth>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 使用下拉框
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Getusecondition()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<UseCondition>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 产羔耳标反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<LamBing> LamBingFind([FromQuery]LamBingFindCommand request)
        {
            return await mediator.Send(request);
        }
        [HttpGet]
        public  async Task<List<LamBing>> LamBingGets([FromQuery]LamBingGetsCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
    }
}
